<?php
    class Wizard_Model extends CI_Model {

        var $strTitle   = '';
        var $strDesc = '';
        var $intType = 0;
        var $strType = '';
        var $table = 'tbwizards';

        function __construct()
        {
            // Call the Model constructor
            parent::__construct();
        }

        function listAll()
        {
            $query = $this->db->get($this->table);
            return $query->result();
        }

        function getPreview($idWizard)
        {
            $query = $this->db->get_where($this->table, array('idWizard' => $idWizard));
            $preview['wizard'] = $query->row();
            #get the questions and answers by the wizard id
            $this->load->model("question_model", "q_model");
            $preview['questions'] = $this->q_model->getQuestionsByWizardID($idWizard);
            return $preview;
        }

        function update_entry()
        {
            $this->title   = $_POST['title'];
            $this->content = $_POST['content'];
            $this->date    = time();

            $this->db->update('entries', $this, array('id' => $_POST['id']));
        }

    }
?>